/*
 * @Author: wangjing 1173862626@qq.com
 * @Date: 2025-05-26 10:36:58
 * @LastEditors: wangjing 1173862626@qq.com
 * @LastEditTime:2025-05-26 10:36:58
 * @FilePath: \neilao-mobile\src\utils\common.ts
 * @Description: 枚举和公共方法
 */
// 获取当前日期的年月日时分数组
export function getCurrentDateTimeArray() {
  const now = new Date();

  return [
    [
      String(now.getFullYear()),          // 年
      String(now.getMonth() + 1).padStart(2, '0'), // 月（从 0 开始，所以要 +1）
      String(now.getDate()).padStart(2, '0') // 日
    ],      
    [
      String(now.getHours()).padStart(2, '0'),     // 时
      String(now.getMinutes()).padStart(2, '0')    // 分
    ]
  ];
}

// 日期格式化
export const formatDate = (v: string) => {
  return v ? new Date(v).toLocaleString() : ''
}

// 巡查工单-状态
export const patrolStatus = [
  // { text: "待派发", value: 0, color: 's0' },
  { text: "处置中", value: 1, class: 's1', color: '#ee7e34' },
  { text: "已完成", value: 2, class: 's2', color: '#0091ff'},
]
export const getPatrolStatus = (v: string, k = 'value') => {
  return patrolStatus.find((item) => item[k as keyof typeof item] == v) || {
    text: '',
    value: '',
    color: '',
    class: '',
  }
}

// 养护工单-状态
export const maintainStatus = [
  { text: "处置中", value: 1, class: 's1', color: '#ee7e34' },
  { text: "已完成", value: 2, class: 's2', color: '#0091ff' },
]
export const getMaintainStatus = (v: string, k = 'value') => {
  return maintainStatus.find((item) => item[k as keyof typeof item] == v) || {
    text: '',
    value: '',
    class: '',
    color: ''
  }
}

// 小修工单-状态
export const minorRepairStatus = [
  { text: "处置中", value: 1, class: 's1', color: '#ee7e34' },
  { text: "已完成", value: 2, class: 's2', color: '#0091ff' },
]
export const getMinorRepairStatus = (v: string, k = 'value') => {
  return minorRepairStatus.find((item) => item[k as keyof typeof item] == v) || {
    text: '',
    value: '',
    color: '',
    class: ''
  }
}

// 收否上报-状态
export const reportStatus = [
  { text: "未上报", value: 0, color: 's0' },
  { text: "已上报", value: 1, color: 's1' }
]
export const getReportStatus = (v: string, k = 'value') => {
  return reportStatus.find((item) => item[k as keyof typeof item] == v) || {
    text: '',
    value: '',
    color: ''
  }
}

// 巡查养护
export const maintenanceStatus = [
  { text: '一般养护', value: '0', color: '#ee7e34' },
  { text: '专项养护', value: '1', color: '#0091ff'}
]
export const getMaintenanceStatus = (v: string, k = 'value') => {
  return maintenanceStatus.find((item) => item[k as keyof typeof item] == v) || {
    text: '',
    value: '',
    color: ''
  }
}

// 设施类型
export const facilityTypeList = [
  { text: '管道类', value: '0' },
  { text: '雨水口类', value: '1'},
  { text: '检查井类', value: '2'},
  { text: '其他类', value: '3'}
]
export const getFacilityType = (v: string, k = 'value') => {
  return facilityTypeList.find((item) => item[k as keyof typeof item] == v) || {
    text: '',
    value: ''
  }
}

// 设施类型 - 问题类型
export const problemTypeList = [
  { text: '功能性缺失', value: '0', pid: '0' },
  { text: '结构性缺陷', value: '1', pid: '0'},

  { text: '雨水箅堵塞', value: '2', pid: '1' },
  { text: '底部积泥或杂物', value: '3', pid: '1'},
  { text: '雨水箅丢失', value: '4', pid: '1'},
  { text: '雨水箅破损', value: '5', pid: '1'},

  { text: '底部积泥或杂物', value: '6', pid: '2' },
  { text: '井盖丢失', value: '7', pid: '2'},
  { text: '防坠设施缺损', value: '8', pid: '2'},

  { text: '排放泥浆', value: '9', pid: '3' },
  { text: '倒灌', value: '10', pid: '3'},
  { text: '违章占压雨水口或检查井', value: '11', pid: '3'}
]
export const getProblemTypeList = (v: string, k = 'value') => {
  return problemTypeList.find((item) => item[k as keyof typeof item] == v) || {
    text: '',
    value: ''
  }
}
